A rootkit is a program or software tool used by a malicious actor to gain unauthorized access to a system.

Rootkits, backdoors, trapdoors, and wormholes are some of the ways to gain privileged access to a system. In the case of a remote-access Trojan, it allows an unauthorized person to take control of another person’s machine. A rootkit may be installed through a worm or buffer overflow. Once installed, it can be difficult to detect or eradicate without rebuilding the entire system.

The historical definition of a rootkit comes from Unix computers that had been attacked, where the malicious actor wanted to maintain “root” or administrator privileges on a computer after a compromise. To accomplish this, the malicious actor installed a variety of modified Unix tools to function as normal while not showing the compromise—an open port to the attacker or malicious files installed on the computer. As a result, the name “rootkit” makes sense, where a “kit” or suite of tools was used to maintain root privileges.

Some have defined Windows rootkits as codes that mask intrusion as well as used in the compromise of a system. Strictly speaking, rootkits are used to maintain elevated privileges on a system by being stealthy.

In Windows, the term “rootkit” identifies malware that attempts to conceal the presence of code on a system by injecting processes, concealing files on the system, and hiding registry keys from users attempting to analyze keys on the system.

Windows rootkits are not necessarily a suite of tools but are often just one or two files. There are four types of Windows rootkits: persistent rootkits, memory-based rootkits, user-mode rootkits, and kernel-mode rootkits. The following are the first three:

One of the most common user-mode techniques is the in-memory modification of system dynamic link libraries (DLLs). Windows programs use common code found in Microsoft-provided DLLs. At runtime, these DLLs are loaded into the application’s memory space, allowing the application to call and execute code in the DLL. A user-mode rootkit might intercept all calls to the Windows FindFirstFile and FindNextFile application programming interfaces (APIs), which are used by file system exploration utilities, including File Explorer and the command prompt, to enumerate the contents of file system directories. When an application performs a directory listing that would otherwise return results that contain entries identifying the files associated with the rootkit, the rootkit intercepts and modifies the output to remove the entries.

The Windows Native API serves as the interface between the user-mode clients and kernel-mode services and the more sophisticated user-mode rootkits intercept file system, registry, and process enumeration functions of the Native API. This prevents their detection by scanners that compare the results of a Windows API enumeration with that returned by a Native API enumeration. However, since user-mode applications all run in their own memory space, the rootkit needs to perform this patching in the memory space of every running application. In addition, the rootkit needs to monitor the system for any new applications that execute and patch those programs’ memory space before they fully execute.

The fourth Windows rootkit is the kernel-mode rootkit that is more powerful than user-mode rootkits because they have the same level of power as an administrator (root-level on Windows).

Software attempting to identify and remove rootkits on a system is in a race to not be manipulated or controlled by hostile code operating on the same layer of access control and permissions.

Kernel-mode rootkits are typically installed as a SYS or VXD file type in the Windows or Windows System32 directories. Kernel-mode rootkits are considered more powerful than other kinds of rootkits since they not only intercept the Native API in kernel-mode but also directly manipulate kernel-mode data structures. A common technique for hiding the presence of a malware process is to remove the process from the kernel’s list of active processes. Since process management APIs rely on the contents of the list, the malware process will not display in process management tools such as Task Manager or Process Explorer.

Kernel-mode rootkits involve system hooking or modification in the kernel space, which is generally off-limits to standard authorized or unauthorized users. One must have the appropriate rights to view or modify kernel memory. The kernel is an ideal place for system hooking because it is at the lowest level and thus is the most reliable and robust method of system hooking. The system call’s path through the kernel passes through a variety of hook points. As a system call’s execution path leaves user mode and enters kernel mode, it must pass through a gate. The purpose of the gate is to ensure that user-mode code does not have general access to kernel-mode space protecting the kernel space. This gate must be able to recognize the purpose of the incoming system call, initiate the execution of code inside the kernel space and then return results back to the incoming user-mode system call. The gate is effectively a proxy between user mode and kernel mode.

The gate proxy is invoked via an interrupt in older versions of Windows, and it is invoked via a model-specific register (MSR) in newer versions of Windows. Both mechanisms can be hooked causing the gate to direct execution to the rootkit rather than the original kernel-mode code.

Another popular hook point is to modify the System Service Descriptor Table (SSDT). The SSDT is a function pointer table in kernel memory that holds all the addresses of the system call functions in kernel memory. By simply modifying this table, the rootkit can redirect execution to its code instead of the original system call. Similarly, to the previously mentioned techniques, the rootkit would likely call the original system call and then remove itself from the results before passing back the results.

Finally, another kernel-mode rootkit technique called direct kernel object modification (DKOM)simply modifies the data structures in kernel memory. For example, kernel memory must keep a list of all running processes, and a rootkit can simply remove itself from this list along with other malicious processes it wishes to hide.